﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Xml.Serialization;
using System.Xml;
namespace Media
{
    /// <summary>
    /// Object containing all the informations about a music media file
    /// </summary>
    public class MusicInfo : AMediaInfo
    {
        #region "Constructeurs"
        /// <summary>
        /// Constructor for serialization use MusicInfo(String path, TagLib.File f) instead
        /// </summary>
        public MusicInfo() : base()
        {
        }

        /// <summary>
        /// Create a new Musicinfo and get all information about the file at the path
        /// </summary>
        /// <param name="path">Path of the file</param>
        /// <param name="f">object created by Taglib sharp containing all informations about the file</param>
        public MusicInfo(String path, TagLib.File f) : base(path, f)
        {
            if (file != null)
            {
                if (file.Properties != null)
                {
                    if (file.Properties.Duration != null)
                        Length = file.Properties.Duration.ToString();
                    BitRates = file.Properties.AudioBitrate.ToString();
                }
                if (file.Tag != null)
                {
                    Author = file.Tag.FirstPerformer;
                    Album = file.Tag.Album;
                    TrackNumber = file.Tag.Track.ToString();
                    Title = file.Tag.Title;
                }
            }
        }
        #endregion
    }
}
